package com.wyb.controller.member;

import com.wyb.entity.Member;
import com.wyb.service.impl.MemberServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet("/member/addMember")
public class AddMemberServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        resp.setCharacterEncoding("utf-8");
        String realName=req.getParameter("realName");
        String nickName=req.getParameter("nickName");
        String mobile=req.getParameter("mobile");
        String sex=req.getParameter("sex");
        int age=Integer.parseInt(req.getParameter("age"));
        int level=Integer.parseInt(req.getParameter("level"));
        int state=Integer.parseInt(req.getParameter("state"));
        boolean b= new MemberServiceImpl().addMember(new Member(null,realName,nickName,mobile,sex,age,level,state));
        PrintWriter pw = resp.getWriter();
        pw.println(b);
        pw.flush();
    }
}
